﻿using System;
using System.Security;
using Microsoft.Win32.SafeHandles;

namespace CardPlay.Presentation.Drawing
{
    internal sealed class BitmapHandle : SafeHandleZeroOrMinusOneIsInvalid
    {
        [SecurityCritical]
        public BitmapHandle(IntPtr preexistingHandle, bool ownsHandle = true) : base(ownsHandle)
        {
            SetHandle(preexistingHandle);
        }

        protected override bool ReleaseHandle()
        {
            return GdiNative.DeleteObject(handle);
        }        

    }
}